home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Development Notes / ODF Shared Library < prev    next >
Encoding:
Text File  |  1996-08-16  |  11.0 KB  |  232 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. ODF Shared Library 
  6. ODF Release 1                                                                                                                                                             
  7.  
  8.  
  9. Table of Contents
  10. • Shipping ODFLibrary
  11. • Release-to-Release Binary Compatibility
  12. • SOM vs. Extern "C" Interfaces
  13. • Public vs private APIs
  14. • C++ Wrapper Classes
  15. • Smart Pointers
  16. • Public Exported Functions (by Subsystem)
  17.  
  18.  
  19. All parts you build with ODF Release 1 require the ODF shared library ODFLibrary 1.0.  ODFLibrary contains code from the Foundation and OS layers of ODF which is shared by all ODF parts.  The design choice to package part of ODF as a shared library has ramifications that you should be aware of when you develop ODF parts.  We discuss the ramifications here.
  20.  
  21.  
  22. Shipping ODFLibrary
  23.  
  24. When you build ODF part editors with ODF Release 1, you must link against ODFLibrary 1.0.  When you ship your editors, you will need to provide an installer.  Install the ODFLibrary along with your part editors into the 'Editors' folder. If an ODFLibrary is already present, make sure to check the version number. Do not install an older version over a more recent one.  The ODFLibrary will maintain release to release binary compatibility so you can be sure that your part editor will always be working with the most recent version. 
  25.  
  26.  
  27. Release-to-Release Binary Compatibility
  28.  
  29. When you ship your part built with ODF Release 1, your part editor (WhizzyPart 1.0) and ODFLibrary 1.0 are installed into the user's Editors folder.  Meanwhile, we're busy developing ODF Release 2.  ODF R2 may have an improved ODFLibrary, say version 1.1. Along the way, we may have discovered and fixed bugs in ODFLibrary and released updates on the net, say versions 1.0.1 and 1.0.2.  Any of these versions could be installed into the Editors folder of  your users of WhizzyPart 1.0.   This means that we (the ODF team) must ensure backwards compatiblity of ODFLibrary, or we'll break all ODF parts built against prior versions of ODFLibrary.
  30.  
  31. Fortunately, the Code Fragment Manager (CFM) and the CFM Runtime make this relatively easy.  We're not allowed to modify any of the exported APIs, but we can add new APIs, fix bugs, and even completely replace implementations beneath the APIs, and still be backwards compatible.
  32.  
  33. Note that classes and APIs defined in the ODF static libraries (i.e. not part of ODFLibrary) can be modified in future releases of ODF.  This means that when we ship ODF Release 2 (and later) that you may need to modify your source code and rebuild your part in order to take advantage of new features and improvements in the architecture.
  34.  
  35.  
  36. SOM vs. Extern "C" Interfaces
  37.  
  38. The code in the ODF library is the implementation for much of the Foundation and OS layers of ODF.  These subsystems in these layers were originally designed as C++ classes, but in order to move the code into a shared library it was necessary to rearchitect the code.  Two choices were available to us: 1) convert the classes to SOM, and 2) convert to procedural APIs using C-style structs and functions (extern "C").  We ended up using both mechanisms.  ODFLibrary 1.0 has 21 SOM classes and 491 extern "C" functions.
  39.  
  40.  
  41. Public vs private APIs
  42.  
  43. If you examine the list of exported functions from ODFLibrary you'll see that most of them (395, to be exact) are named FW_PrivXXX.  Functions in ODF which begin with the "Priv" prefix are considered private, or internal, to ODF.  They are used internal to the implementation of ODF, but need never be called in order to write fully functional ODF part editors.  In general, Priv functions are low-level (private) interfaces which are used by the implementation of higher-level (public) interfaces.  This is definitely the case for the Priv functions in ODF Library. For example, ODFLibrary exports 42 private functions that begin with the prefix "FW_PrivString_".  These functions are all implementations for the methods of the public class FW_CString.  FW_CString is a normal C++ class, and is statically linked into every ODF part.  However, every method of FW_CString is implemented as a single call to one of the FW_PrivString functions in ODFLibrary, so only a small amount of code is statically linked into your part. 
  44.  
  45.  
  46. C++ wrapper classes
  47.  
  48. FW_CString is an example of a wrapper class.  Wrapper classes are thin wrappers around some other implementation.  ODF uses wrapper classes for much of the functionality implemented in ODFLibrary.  These wrapper classes are part of the public interface of ODF and are fully documented.  It is interesting to note that wrapper classes allowed us to minimize the impact of moving to a shared library architecture.  In ODF R1 there are wrapper classes whose interfaces are nearly identical to the full-fledged C++ classes from ODF 1.0d11.
  49.  
  50. Wrapper classes are not just used for wrapping the procedural C functions in ODFLibrary.  ODF provides some wrapper classes that wrap SOM classes from the ODF library as well.  For example,  FW_OFile is a SOM class defined in ODFLibrary.  In previous (pre-)releases of ODF, files were implemented using the FW_CFile class.  FW_CFile was designed to normally be used as a stack-based object.  Creating a FW_CFile  object opened the file, and destroying the FW_CFile object closed the file.  By placing the object on the stack, it was possible to guarantee that the file would be closed when the object went out of scope, even if the scope was exitted due to an exception.  SOM classes, however, cannot be created on the stack.  We didn't want to give up the exception safety we get from creating FW_CFile objects on the stack, so we created a C++ class to wrap the FW_OFile class.
  51.  
  52.  
  53. Smart Pointers
  54.  
  55. FW_PFile is a C++ class that wraps the SOM class FW_OFile.  FW_PFile and FW_OFile together provide an interface and functionality almost identical to the old class FW_CFile.  Developers who used pre-release versions of ODF and had references to FW_CFile objects can very likely just search for FW_CFile and replace it with FW_PFile and their code will work (assuming other similar renamings are performed, and some . operators are changed to -> operators). So why didn't we leave FW_CFile named as it was? FW_PFile uses the P prefix instead of the C prefix because it is a smart pointer.  A smart pointers is an instance of class that defines operator->() so that it can act as a pointer to some other representation object .  FW_PFile is a class that has a data member which is a pointer to a FW_OFile representation object, and overrides operator->() to allow access to the FW_OFile object.  Given an instance of FW_PFile, you can directly call any of the public member functions of FW_OFile.  Note that by simply defining operator-> the class effectively inherits all of the public protocol of the representation class.  However, this protocol doesn't appear in the class declaration for the smart pointer, so it can be easy to not realize the protocol is available.  We use the P prefix so that you'll remember that you can use the protocol of the representation class.
  56.  
  57.  
  58. Public Exported Functions (by Subsystem)
  59.  
  60. There are 21 SOM classes and 96 public procedures exported by the ODFLibrary.  The following summarizes, by subsystem, the public APIs from ODFLibrary for each subsystem.  Note that some subsystems have no public APIs exported by ODFLibrary.  In all such cases, there will be public APIs defined by classes in one of the ODF static libraries that are linked into your part.  See the ODF Class Reference or Engineering Notes for more information.
  61.  
  62. NOTE: We chose to use SOM to make the 21 SOM classes so that it would be possible to create subclasses. However, it is not required that you subclass any of the 21 SOM classes below, and most ODF part developers will have no need to do so.  Furthermore, there exist public C++ wrappers for most of the SOM classes.
  63.  
  64. Foundation::FWCommon
  65.  
  66. This subsystem defines the following public functions:
  67. FW_PrimitiveSetMemory
  68. FW_PrimitiveCopyMemory
  69. FW_PrimitiveFreeBlock
  70. FW_PrimitiveGetBlockSize
  71. FW_PrimitiveResizeBlock
  72. FW_PrimitiveAllocateBlock
  73. FW_PrimitiveCharacterIsSpace
  74. FW_PrimitiveCharacterToLower
  75. FW_PrimitiveCharacterToUpper
  76. FW_PrimitiveStringFindCharacter
  77. FW_PrimitiveStringCatenate
  78. FW_PrimitiveStringCopy
  79. FW_PrimitiveStringDuplicate
  80. FW_PrimitiveStringCompare
  81. FW_PrimitiveStringEqual
  82. FW_PrimitiveStringLength
  83. FW_Thread_NoteCreation
  84. FW_Thread_NoteTermination
  85. FW_Thread_NoteSwitch
  86.  
  87. Foundation::FWCollect
  88.  
  89. All exported functions are private.
  90.  
  91. Foundation::FWDebug
  92.  
  93. All exported functions are private.
  94.  
  95. Foundation::FWRunTyp
  96.  
  97. No functions are exported from the shared library.
  98.  
  99. Foundation::FWExcLib
  100.  
  101. No functions are exported from the shared library.
  102.  
  103. Foundation::FWMemory
  104.  
  105. All exported functions are private.
  106.  
  107. Foundation::FWStream
  108.  
  109. All exported functions are private.
  110. This subsystem defines six SOM classes: 
  111. FW_OSink
  112. FW_OBufferedSink
  113. FW_OMemorySink
  114. FW_OObjectRegistry
  115. FW_OBasicObjectRegistry
  116. FW_ORandomAccessSink
  117.  
  118. Foundation::FWString
  119.  
  120. All exported functions are private.
  121.  
  122. This subsystem defines five SOM classes: 
  123. FW_OTextRunReader
  124. FW_OTextRunWriter
  125. FW_OMemoryRunReader
  126. FW_OMemoryRunWriter
  127. FW_OStringRunWriter
  128.  
  129. Foundation::FWRefCnt
  130.  
  131. This subsystem defines one SOM class:
  132. FW_ORefCount
  133.  
  134. OS::FWFiles
  135.  
  136. This subsystem defines four SOM classes:
  137. FW_OFile
  138. FW_OFileSink
  139. FW_OFileSpecification
  140. FW_ODirectorySpecification
  141.  
  142. OS::FWOSMisc
  143.  
  144. All exported functions are private.
  145.  
  146. OS::FWODMisc
  147.  
  148. All exported functions are private.
  149.  
  150. This subsystem defines one SOM class:
  151. FW_OStorageUnitSink
  152.  
  153. OS::FWResour
  154.  
  155. This subsystem defines four SOM classes:
  156. FW_OResourceFile
  157. FW_OResource
  158. FW_OResourceSink
  159.  
  160. OS::FWToolbx
  161.  
  162. This subsystem defines the following public functions:
  163. FW_MacGetMaxIntersectedDevice
  164. FW_MacZoomWindow
  165. FW_CenterRectOnScreen
  166. FW_GetMainScreenBounds
  167. FW_Beep
  168. FW_GetTickCount
  169. FW_PositionModalDialog
  170. FW_FitWindowToScreen
  171. FW_SetWindowSize
  172. FW_SetWindowPosition
  173. FW_GetWindowSize
  174. FW_GetWindowPosition
  175. FW_SetWindowTitle
  176. FW_GetWindowTitle
  177. FW_GetWindowBorderSize
  178. FW_ScreenToWindow
  179. FW_WindowToScreen
  180.  
  181. OS::FWGraphics
  182.  
  183. This subsystem defines the following public functions:
  184. FW_MacRGBToColor
  185. FW_MacColorToRGB
  186. FW_GetPaletteSize
  187. FW_SetPaletteEntries
  188. FW_GetPaletteEntries
  189. FW_DestroyPalette
  190. FW_NewRegion
  191. FW_CreateRectRegion
  192. FW_CreateOvalRegion
  193. FW_CreateRoundRectRegion
  194. FW_CreateArcRegion
  195. FW_CreatePolygonRegion
  196. FW_CreateLineRegion
  197. FW_DisposeRegion
  198. FW_CopyRegion
  199. FW_CopyRegionTo
  200. FW_GetRegionBoundingBox
  201. FW_OutlineRegion
  202. FW_EmptyRegion
  203. FW_InsetRegion
  204. FW_MapRegion
  205. FW_OffsetRegion
  206. FW_PointInRegion
  207. FW_RectInRegion
  208. FW_IsEmptyRegion
  209. FW_WriteRegion
  210. FW_ReadRegion
  211. FW_UnionRegion
  212. FW_XorRegion
  213. FW_SubtractRegion
  214. FW_IntersectRegion
  215. FW_RegionCode
  216. FW_PtInOval
  217. FW_PtInRoundRect
  218. FW_HitTestLine
  219. FW_HitTestPolygon
  220. FW_LogPoint
  221. FW_LogRect
  222. FW_LogShape
  223. FW_LogTransform
  224.  
  225. Framework::FWSemEvt
  226.  
  227. This subsystem defines one SOM class:
  228. FW_OSemanticInterface
  229.  
  230.  
  231. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  232. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.